package com.liu.efk.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.liu.efk.domain.Duser;
import com.liu.efk.domain.DuserInvite;
import com.liu.efk.domain.ResultVo;
import com.liu.efk.service.IDuserService;
import com.liu.efk.service.IUserInviteService;
import com.liu.efk.utils.PageUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.naming.ldap.PagedResultsControl;
import java.util.List;

@RestController
@RequestMapping("/userInvite")
@CrossOrigin
@Api(tags = "邀请码管理接口")
public class UserInviteController {

    @Value("${server.version}")
    private String version;


    @Autowired
    IUserInviteService userInviteService;

    @GetMapping("/list")
    @ApiOperation("查询所有邀请码接口")
    public ResultVo userList(){

      List<DuserInvite> list = userInviteService.list();

      return  ResultVo.success("返回用户列表++"+version,list);
    }


    @GetMapping("/pageList")
    @ApiOperation("分页查找邀请码接口")
    public ResultVo userPageList(Integer  num,Integer  rows){
        Page<DuserInvite> page =new Page<DuserInvite>(num,rows);

         userInviteService.page(page,null);


        return  ResultVo.success("返回用户列表++"+version,PageUtils.getResultMap(page.getTotal(),page.getRecords()));
    }




}
